$(document)
.ready(function(){
	
    	var uploader = new plupload.Uploader({
    		//对运行环境的检测
    		runtimes : 'html5,flash,silverlight,html4',
    		//设置选择文件的标签的id；
    		browse_button : 'fileSelect', // you can pass in id...
    		//container: document.getElementById('container'), // ... or DOM Element itself
    		//后台处理的路径
    		url : 'upload.do',
    		//内置的脚本
    		flash_swf_url : '../js/Moxie.swf',
    		silverlight_xap_url : '../js/Moxie.xap',
    		//图片的类型和图片的最大的容量
    		filters : {
    			max_file_size : '10mb',
    			mime_types: [
    				{title : "Image files", extensions : "jpg,gif,png"},
    				{title : "Zip files", extensions : "zip"}
    			]
    		},
    		
    		//初始化图片上传
    		init: {
    			PostInit: function() {
    				document.getElementById('list').innerHTML = '';

    				document.getElementById('fileSelect').onclick = function() {
    					
    					return false;
    				};
    			},
    			BeforeUpload : function(up, file) {
    				
    				up.settings.url = encodeURI("./upload.do?" + "name="+ file.name+"&type="+file.type+"&size="+file.size);

    			},
    			//添加上传文件的操作
    			FilesAdded: function(up, files) {
    				//设置限制的图片数量
    				 if(up.files.length > 5 || uploader.files.length > 5)
    				 {
    				  alert('只能上传5个图片');
    				  return false;
    				 }
    				plupload.each(files, function(file) {
    					document.getElementById('list').innerHTML += "<li id='"+file.id+"'>"+file.type+"</td><td>"+file.name+"</td><td><button type='button' id='"+file.id+"btn' onclick=del('"+file.id+"')>删除</button><span></span></li>";
    				});
    			},

    			//上传的进度设置
    			UploadProgress: function(up, file) {
    				document.getElementById(file.id).getElementsByTagName('span')[0].innerHTML=+ file.percent + "%";
    			},
    			
    			//所有文件上传成功的操作
    			UploadComplete : function(uploader, files) {
    				alert(les.length+"个文件上传成功");
    			},
    			//单个文件上传成功的操作
    			FileUploaded : function(up, file) {
    				
    			},
    			//上传时的错误处理
    			Error: function(up, err) {
    				document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
    			}
    		}
    	});
    	
    	//上传组件初始化
    	uploader.init();

    $("#uploadFile").delegate($(this),'click',function(){
    	//开始上传图片
    	uploader.start();
    });


	
});